<?php
	$op=$_POST["op"];
	if (isset($op) && $op=="login") 
		$ok=validar_ingreso();
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Login</title>
	<link rel="stylesheet" href="css/style.css" type="text/css">
	<link rel="stylesheet" href="css/form.css" type="text/css">
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/prefixfree.min.js"></script>
	<script type="text/javascript" src="js/validacion.js"></script>
	<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
	<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
</head>
<body>
	<?php if($op && !$ok){
		?>
 		<script type="text/javascript">
			alert('Contraseña Incorrecta')
		</script>
	<?php
	} ?>
	<div class="top">
		<img class="img" src="img/logo.png" alt="" height="82" >
		<span id="encabezado">Plataforma de Solicitud de Servicios</span>
	</div>
	<div class="contenido">
		<h2>Acceso Administrativo</h2>
		<h2>Ingrese sus datos de acceso</h2>
		<form method="post" id="login" action="<?php print($_SERVER["PHP_SELF"]);?>">
			<input type="hidden" name="op" value="login"/>
			<div>
				<label for="usuario">Usuario</label>
				<input id="usuario" name="usuario" type="text">
				<span id="usuarioInfo"></span>
			</div>
			<div>
				<label for="contrasenia">Contraseña</label>
				<input id="contrasenia" name="contrasenia" type="password">
				<span id="contraseniaInfo"></span>
			</div>
			<div>
				<input id="enviar" name="enviar" type="submit" value="Aceptar">
			</div>
		</form>
		<?php
			function validar_ingreso(){
				
				$usuario = $_POST["usuario"];
				$contrasenia = $_POST["contrasenia"];
				require_once('includes/conexionbd.inc.php');
				

				$query1 = "Select * from view_login_tutor where correo_1_tutor='$usuario' and contrasena_tutor='$contrasenia'";
				$query2 = "Select * from view_login_coord where correo_coord='$usuario' and contrasena_coord='$contrasenia'";
				$res1 = mysql_query($query1, $conn);
				$res2 = mysql_query($query2, $conn);

				
				if ($res2){
					if ($reg = mysql_fetch_object($res2)){
     					session_start();
     					$_SESSION["correo_coord"]=$reg;
			    		header("Location: coordinador.php"); 
     					mysql_close($conn);
     					return true;
     				};
				};
				
				
				if ($res1){
					if ($reg = mysql_fetch_object($res1)){
     					session_start();
     					$_SESSION["correo_1_tutor"]=$reg;
			    		header("Location: tutor.php"); 
     					mysql_close($conn);
     					return true;
     				};
				};
			

				
				


			

				mysql_close($conn);
			} 
		?>
	</div>
	<div class="footer">
		<ul>
			<li><b>Calle 100 No. 8 55 Torre C Piso 10 World Trade Center</b></li>
			<li><b>Teléfono</b> <span>646 71 23</span></li>
			<li><b>Fax</b> <span>621 15 65</span></li>
		</ul>
		<article class="redes">
			<g:plusone></g:plusone>
		</article>
		<article class="redes">
			<iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2Fpages%2FTecnologia-Online%2F146028292143954&amp;send=false&amp;layout=button_count&amp;width=110&amp;show_faces=true&amp;action=like&amp;colorscheme=dark&amp;font=tahoma&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:21px;" allowTransparency="true"></iframe></li>
		</article>
		<article class="redes">
			<a href="https://twitter.com/lleoz" class="twitter-follow-button" data-show-count="false" data-lang="es" data-size="large">Sigueme @lleoz</a></li>
		</article>
	</div>
</body>